import { api } from '@/utils/request'
import type { Countdown, CreateCountdownRequest, UpdateCountdownRequest } from '@/types/countdown'

/**
 * 获取所有倒计时
 */
export const getCountdowns = () => {
  return api.get<Countdown[]>('/countdowns')
}

/**
 * 获取单个倒计时
 */
export const getCountdown = (id: number) => {
  return api.get<Countdown>(`/countdowns/${id}`)
}

/**
 * 创建倒计时
 */
export const createCountdown = (data: CreateCountdownRequest) => {
  return api.post<Countdown>('/countdowns', data)
}

/**
 * 更新倒计时
 */
export const updateCountdown = (id: number, data: UpdateCountdownRequest) => {
  return api.put<Countdown>(`/countdowns/${id}`, data)
}

/**
 * 删除倒计时
 */
export const deleteCountdown = (id: number) => {
  return api.delete(`/countdowns/${id}`)
}
